import 'package:flutter/material.dart';
import 'package:yurun_smartmerchants/global.dart';
import 'package:yurun_smartmerchants/routes/routes.dart';
import 'package:yurun_smartmerchants/utils/app_size.dart';

class WelcomePage extends StatefulWidget {
  @override
  _WelcomeState createState() => _WelcomeState();
}

class _WelcomeState extends State<WelcomePage> {
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _jump();
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    AppSize.init(context);
    return Scaffold(
      body: Center(
        child: Text(
          '欢迎使用',
          style: TextStyle(fontSize: 24, color: Colors.black),
        ),
      ),
    );
  }

  void _jump() {
    String token = Global.prefs.getString(Global.token);
    Future.delayed(Duration.zero,(){
      if (token == null) {
        Navigator.pushNamedAndRemoveUntil(context, login_page, (route) => false);
      } else {
        Navigator.pushNamedAndRemoveUntil(context, home_page, (route) => false);
      }
    });
  }
}
